package cac.fenjian.resource.WmsItemInv.service;

import cac.fenjian.resource.WmsItemInv.dao.WmsItemInvDao;
import cac.fenjian.resource.WmsItemInventory.dto.WmsItemInventoryDTO;
import com.cac.dme.adapter.rest.msg.QueryReqBean;
import com.cac.dme.adapter.rest.msg.QueryRespBean;
import com.cac.dme.adapter.utils.PageHelper;
import com.cac.dme.common.exception.service.DaoException;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

@Service
public class WmsItemInvService {

    @Autowired
    private WmsItemInvDao wmsItemInventoryDao;
    //库存台账查询
    public PageInfo searchInventoryInfoByPage(HashMap map){
        HashMap page = (HashMap) map.get("page");
        HashMap searchParam = (HashMap) map.get("searchParam");
        int currentPage = Integer.parseInt(page.get("currentPage").toString());
        int pageSize = Integer.parseInt(page.get("pageSize").toString());
        com.github.pagehelper.PageHelper.startPage(currentPage,pageSize);
        List list = wmsItemInventoryDao.searchInventoryInfoByPage(searchParam);
        return new PageInfo(list);
    }

    public List<HashMap> queryItemPallet(HashMap map){
        return wmsItemInventoryDao.queryItemPallet(map);
    }
    public List<HashMap> searchDepartureOccupation(HashMap map){
        return wmsItemInventoryDao.searchDepartureOccupation(map);
    }

    //台账单机数量查询
    public QueryRespBean<HashMap> searchSingleQty(QueryReqBean<HashMap> queryReqBean, String orderBy, String Keywords){

        QueryRespBean<HashMap> queryRespBean =new QueryRespBean<>();
        try {
            PageHelper.startPage(queryReqBean.getPageParameter());
            HashMap searchParams = queryReqBean.getSearchParams();
            Page<HashMap> dataList = wmsItemInventoryDao.searchSingleQty(searchParams,orderBy,Keywords);
            queryRespBean.setResult(dataList);
            return queryRespBean;
        }catch (Exception e) {
            throw new DaoException(e.getMessage(), e);
        }
    }
}
